package com.hnas.core.util;

import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ObjectUtil {
    private static ObjectMapper mapper;  
    
    /** 
     *  
     * @param createNew 
     *          是否创建一个新的Mapper 
     * @return 
     */  
    public static synchronized ObjectMapper getMapperInstance(boolean createNew) {  
        if (createNew) {  
            return new ObjectMapper();  
        } else if (mapper == null) {  
            mapper = new ObjectMapper();  
            mapper.configure(MapperFeature.AUTO_DETECT_FIELDS, false);
        }  
        return mapper;  
    }  
}
